package org.example.cake.mapper;



import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import org.apache.ibatis.annotations.*;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;

import org.example.cake.entity.Discount;
import org.example.cake.entity.Festival;

import java.util.List;

@Mapper
public interface DiscountMapper {
    int deleteByPrimaryKey(Integer discountid);

    int insert(Discount record);

    int insertSelective(Discount record);

    Discount selectByPrimaryKey(Integer discountid);

    int updateByPrimaryKeySelective(Discount record);

    int updateByPrimaryKey(Discount record);

    /**
     * 查询所有优惠券
     * @return 优惠券集合
     * 徐
     */
    public List<Discount> selectAllDiscount(@Param("discountname")String discountname,@Param("status")Integer status);

    /**
     * 通过userid查询所拥有的优惠券
     * @param userid 用户id
     * @return 优惠券集合
     */
    public List<Discount> selectDiscountByUserid(@Param("userid") Integer userid);

    /**
     * //新增后台优惠券信息
     * @author 徐
     * @param discount 优惠券对象
     * @date 2025-08-01
     * @return 受影响的行数
     */
    public int insertDiscountEnd(Discount discount);

    /**
     * //后台优惠券删除（根据id删除）
     * @author 徐
     * @param discountid 优惠券id
     * @date 2025-08-01
     * @return 优惠券id
     */
    public int deleteDiscountEnd(@Param("discountid")Integer discountid);

    /**
     * //修改后台优惠券信息
     * @author 徐
     * @param discount 优惠券对象
     * @date 2025-08-01
     * @return 受影响的行数
     */
    public int updateDiscountEnd(Discount discount);

    /**
     * 第一次登录得到的优惠券
     * @return 优惠券集合
     */
    public List<Discount> selectTwoDiscount();

    /**
     * 新增优惠券
     * @param discount 优惠券对象
     * @return 受影响的行数
     */
    @Insert("INSERT INTO discount(money,maxmoney,starttime,endtime,STATUS,discountname)\n" +
            "VALUES(#{money}, #{maxmoney} ,#{starttime} ,#{endtime} ,#{status} ,#{discountname} )")
    @Options(useGeneratedKeys = true,keyProperty = "discountid")
    public int insertDiscount(Discount discount);

    /**
     * 根据优惠券id查询优惠券
     * @param discountid 优惠券id
     * @return 优惠券实体
     */
    @Select("select * from discount where discountid=#{discountid} ")
    public Discount selectById(@Param("discountid") Integer discountid);








}